package com.example.counter;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    public  static  final  String TAG="fenshu";
    public  static  final  String TAG2="jiafen";
    TextView score_A;
    String s1_A;
    Integer s2_A;
    TextView score_B;
    String s1_B;
    Integer s2_B;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        score_A=findViewById(R.id.score_A);
        s1_A=score_A.getText().toString();
        s2_A=Integer.parseInt(s1_A);
        Log.i(TAG,"onCreate():score="+s2_A);

        score_B=findViewById(R.id.score_B);
        s1_B=score_B.getText().toString();
        s2_B=Integer.parseInt(s1_B);
    }
    public void Aclick_3(View v) {
        jisuan_A(3);
    }
    public void Aclick_2(View v) {
        jisuan_A(2);
    }
    public void Aclick_free(View v) {
        jisuan_A(-1);
    }
    public void Bclick_3(View v) {
        jisuan_B(3);
    }
    public void Bclick_2(View v) {
        jisuan_B(2);
    }public void Bclick_free(View v) {
        jisuan_B(-1);
    }
    public void reset(View v) {
        s2_A=0;
        s2_B=0;
        s1_A=String.valueOf(s2_A);
        s1_B=String.valueOf(s2_B);
        score_A.setText(s1_A);
        score_B.setText(s1_B);
    }
    public void  jisuan_A(int i){
        s2_A=s2_A+i;
        s1_A=String.valueOf(s2_A);
        score_A.setText(s1_A);
    }
    public void  jisuan_B(int i){
        s2_B=s2_B+i;
        s1_B=String.valueOf(s2_B);
        score_B.setText(s1_B);
    }
}